<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <h1>我的微博列表</h1>
  <div v-for="w in arr">
    <h3>{{w.content}}</h3>
    <p>发布于：{{w.created}} <a href="javascript:void(0)" @click="del(w.id)">删除</a></p>
  </div>
</div>
</body>
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      arr: []
    },
    methods: {
        del(id) {
            axios.post("/weibo/deleteMyWeibo?id=" + id).then(function () {
                if (confirm("确认删除吗？")) {
                    location.reload();
                }
            })
        }
    },
    created:function () {
      axios.get("/weibo/selectByUserId").then(function (response) {
        if (response.data.code == 2) {
          alert("请先登录！");
          location.href = "/login.html";
        } else {
          v.arr = response.data.data;
        }
      })
    }
  })
</script>
</html>